<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/9/19 0019
 * Time: 09:37
 */

namespace app\api\controller\v1;


use app\currency\service\CitiesService;
use library\Controller;
use think\Db;

class CitiesContact extends Controller
{
    public function index()
    {
        echo 'success';
    }
    /**
     * 根据电话查询可用联系人
     * @param $id
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function read($id)
    {
        $where = [['contact_phone','eq',$id]];
        $list = Db::name('Cities')
            ->alias('a')
            ->where($where)
            ->whereNotExists('SELECT * FROM cities_cleaner WHERE a.id=cities_cleaner.cities_id')
            ->order('id desc')->select();
        foreach ($list as &$item) {
            $item['address'] = CitiesService::getAddressText($item['id'],'string');
        }
        $this->success('success',$list);
    }
}